01. Practice: Apply What You've Learned
Practice Debugging
This practice session will focus on debugging, which is one of the five ways programmers think. Python requires code be written with a very specific syntax. This means that small typos can lead to big problems!
In each of the following exercises, you'll be given code. Sometimes the code will work and sometimes it won't. For each exercise, do the following:
- Read through the code and try to predict what it is supposed to do.
- Make a guess about whether or not it will actually work.
- Without modifying the code yet, press the
Test Runbutton. - Observe the output that's displayed.
- If there's an error message, read through it.
- These error messages are usually very cryptic. That's okay. Go through each message and try to decipher what the actual problem was. If you can figure it out, fix the code and then press
Test Runagain.
HINT: It's often a good idea to start at the last line of the error message.
Debugging!